The Chinese meaning of sealed is sealed. The old name "sealed" means that the classes or Methods Modified by sealed cannot be inherited or overwritten.
The role of the sealed Keyword:
Using sealed in class declaration can prevent other classes
Sealed and final modifiers are not actually a product of a language platform, they have their own locale, but these two keywords are. NET platform, then the use of both geometry, with this article to explore.I.SealedThe sealed modifier can be
Reprint Original Address http://developer.51cto.com/art/200908/147327.htmC # language is more common, here we mainly introduce C # sealed modifier, including the introduction of two modifiers in the meaning of mutually exclusive use of methods and
New
The New Keyword can explicitly hide members inherited from the base class. Hiding inherited members means that the derived version of the member replaces the base class version.That is to say, the method used to use the derived class is
1. Sealed keywordWhen the sealed modifier is applied to a class, this modifier prevents other classes from inheriting from the class. Similar to the final keyword in java.In the following example, Class B inherits from class A, but no class can
Bo Master these days just idle, smashing Foundation, after all, self-study, foundation is not reliable very deadly, to be practical AH ~ ~ ~The 1.sealed keyword modifies a class and can also decorate an implementation method or property. When sealed
Internal
Declared Class, Class Member, interface or interface member has internal visibility.
The internal modifier makes the class, interface, or member visible only in the current package. Code outside the current package cannot access
Use in two cases:????· do not want others to inherit, for example public sealed class person{};????· don't want subclasses to rewrite their own methods???? For example:???????? public class person{Public visual void Sayhi () {}}???????? public class
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->/*
* Created by sharpdevelop.
* User: noo
* Date: 2009-8-16
* Time:
*
* Seal
*/
Using system;
Sealed Class A // sealed class, Keyword: sealed
{
Public
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.